package com.c6906.vdam.das.model.entity;

import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONConfig;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.c6906.vdam.das.common.EWTypeEnum;
import com.c6906.vdam.das.common.SnowFlakeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

@Data
@ApiModel(description = "监督管理_预警明细表")
@TableName("ew_vehicles_warn_detail")
public class EWVehiclesWarnDetail implements Serializable {

    @TableId
    @ApiModelProperty(value = "明细id")
    private Long id;

    @ApiModelProperty(value = "预警id")
    private Long ewId;

    @ApiModelProperty(value = "组织层级编码")
    private String regionCode;

    @ApiModelProperty(value = "组织层级名称")
    private String regionName;

    @ApiModelProperty(value = "预警类型编码")
    private String ewTypeId;

    @ApiModelProperty(value = "预警类型名称")
    private String ewTypeName;

    @ApiModelProperty(value = "业务编码类型（10用车申请编码20编制申请编码30处置申请编码）")
    private String objectType;

    @ApiModelProperty(value = "业务编码")
    private String objectCode;

    @ApiModelProperty(value = "预警详情")
    private String ewRemark;

    @ApiModelProperty(value = "权属单位id")
    private Long ownUnitId;

    @ApiModelProperty(value = "权属单位名称")
    private String ownUnitName;

    @ApiModelProperty(value = "使用单位id")
    private Long useUnitId;

    @ApiModelProperty(value = "使用单位名称")
    private String useUnitName;

    @ApiModelProperty(value = "创建人")
    private Long createUser;

    @ApiModelProperty(value = "创建人姓名")
    private String createUserName;

    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "修改人")
    private Long updateUser;

    @ApiModelProperty(value = "修改人姓名")
    private String updateUserName;

    @ApiModelProperty(value = "修改时间")
    private Date updateTime;

    @ApiModelProperty(value = "状态")
    private Integer status;

    @ApiModelProperty(value = "默认0")
    private Integer isDeleted;

    @ApiModelProperty(value = "预警信息")
    private String objectRemark;

    public EWVehiclesWarnDetail(EWVehiclesIllegalParking ewVehiclesIllegalParking, EWVehiclesWarn ewVehiclesWarn, TerminalBusinessInfo tbi) {
        this.id = SnowFlakeUtil.getFlowIdInstance().nextId();
        this.ewId = ewVehiclesWarn.getEwId();
        this.regionCode = tbi.getRegionCode();
        this.regionName = tbi.getRegionName();
        this.ewTypeId = EWTypeEnum.ILLEGAL_PARK.getId();
        this.ewTypeName = EWTypeEnum.ILLEGAL_PARK.getName();
        this.objectType = "10";
        this.ewRemark = ewVehiclesWarn.getEwRemark();
        this.ownUnitId = Long.parseLong(tbi.getOwnUnitId());
        this.ownUnitName = tbi.getOwnUnitName();
        this.useUnitId = Long.parseLong(tbi.getUseUnitId());
        this.useUnitName = tbi.getUseUnitName();
        this.createUser = 100L;
        this.createUserName = "系统自动处理";
        this.createTime = DateUtil.date();
        this.status = 1;
        this.isDeleted = 0;
        this.objectRemark = JSONUtil.toJsonStr(ewVehiclesIllegalParking, JSONConfig.create().setDateFormat("yyyy-MM-dd HH:mm:ss"));
    }

    public EWVehiclesWarnDetail(EWVehiclesNoTask ewVehiclesNoTask, EWVehiclesWarn ewVehiclesWarn, TerminalBusinessInfo tbi) {
        this.id = SnowFlakeUtil.getFlowIdInstance().nextId();
        this.ewId = ewVehiclesWarn.getEwId();
        this.regionCode = tbi.getRegionCode();
        this.regionName = tbi.getRegionName();
        this.ewTypeId = EWTypeEnum.NO_TASK.getId();
        this.ewTypeName = EWTypeEnum.NO_TASK.getName();
        this.objectType = "10";
        this.ewRemark = ewVehiclesWarn.getEwRemark();
        this.ownUnitId = Long.valueOf(tbi.getOwnUnitId());
        this.ownUnitName = tbi.getOwnUnitName();
        this.useUnitId = Long.parseLong(tbi.getUseUnitId());
        this.useUnitName = tbi.getUseUnitName();
        this.createUser = 100L;
        this.createUserName = "系统自动处理";
        this.createTime = DateUtil.date();
        this.status = 1;
        this.isDeleted = 0;
        this.objectRemark = JSONUtil.toJsonStr(ewVehiclesNoTask, JSONConfig.create().setDateFormat("yyyy-MM-dd HH:mm:ss"));
    }

    public EWVehiclesWarnDetail(EWVehiclesUnauthTask ewVehiclesUnauthTask, EWVehiclesWarn ewVehiclesWarn, TerminalBusinessInfo terminalBusinessInfo) {
        this.id = SnowFlakeUtil.getFlowIdInstance().nextId();
        this.ewId = ewVehiclesWarn.getEwId();
        this.regionCode = terminalBusinessInfo.getRegionCode();
        this.regionName = terminalBusinessInfo.getRegionName();
        this.ewTypeId = EWTypeEnum.UNAUTH_TASK.getId();
        this.ewTypeName = EWTypeEnum.UNAUTH_TASK.getName();
        this.objectType = "10";
        this.ewRemark = ewVehiclesWarn.getEwRemark();
        this.ownUnitId = Long.valueOf(terminalBusinessInfo.getOwnUnitId());
        this.ownUnitName = terminalBusinessInfo.getOwnUnitName();
        this.useUnitId = Long.valueOf(terminalBusinessInfo.getUseUnitId());
        this.useUnitName = terminalBusinessInfo.getUseUnitName();
        this.createUser = 100L;
        this.createUserName = "系统自动处理";
        this.createTime = DateUtil.date();
        this.status = 1;
        this.isDeleted = 0;
        this.objectRemark = JSONUtil.toJsonStr(ewVehiclesUnauthTask, JSONConfig.create().setDateFormat("yyyy-MM-dd HH:mm:ss"));
    }

    public EWVehiclesWarnDetail(EWVehicleDetail ewVehicleDetail, EWVehiclesWarn ewVehiclesWarn, TerminalBusinessInfo terminalBusinessInfo) {
        this.id = SnowFlakeUtil.getFlowIdInstance().nextId();
        this.ewId = ewVehiclesWarn.getEwId();
        this.regionCode = ewVehicleDetail.getRegionCode();
        this.regionName = ewVehicleDetail.getRegionName();
        this.ewTypeId = EWTypeEnum.ILLEGAL_PLACE.getId();
        this.ewTypeName = EWTypeEnum.ILLEGAL_PLACE.getName();
        this.objectType = "10";
        this.ewRemark = ewVehiclesWarn.getEwRemark();
        this.ownUnitId = Long.valueOf(terminalBusinessInfo.getOwnUnitId());
        this.ownUnitName = terminalBusinessInfo.getOwnUnitName();
        this.useUnitId = ewVehicleDetail.getUseUnitId();
        this.useUnitName = ewVehicleDetail.getUseUnitName();
        this.createUser = 100L;
        this.createUserName = "系统自动处理";
        this.createTime = DateUtil.date();
        this.status = 1;
        this.isDeleted = 0;
        this.objectRemark = JSONUtil.toJsonStr(ewVehicleDetail, JSONConfig.create().setDateFormat("yyyy-MM-dd HH:mm:ss"));
    }
}